#include <iostream>
#include <list>
using namespace std;
int main()
{
	int n, m; cin >> n >> m;
	list<int> l;
	for (int i = 1; i <= n; i++) l.push_back(i);
	auto it = l.begin();
	int jug = 0;
	while (l.size())
	{
		if (jug) cout << ' '; jug = 1;
		int k = m - 1;
		while (k--)
			if (++it == l.end())
				it = l.begin();
		cout << *it;
		if ((it = l.erase(it)) == l.end())
			it = l.begin();
	}
	return 0;
}